using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SetFileDate
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string m;
            if (!cbCreate.Checked && !cbLastAccess.Checked && !cbLastWrite.Checked)
            {
                m = "You have to pick at least one type of DateTime to modify\n\nNo changes were made.";
            }
            else
            {
                string f = this.textBox1.Text;
                m = "File:\t" + f + "\n\nDateTimes:\t";
                DateTime dt = this.dateTimePicker1.Value.Date + this.dateTimePicker2.Value.TimeOfDay;
                if (cbCreate.Checked)
                {
                    m += "Create ";
                    File.SetCreationTime(f, dt);
                }
                if (cbLastAccess.Checked)
                {
                    m += "LastAccess ";
                    File.SetLastAccessTime(f, dt);
                }
                if (cbLastWrite.Checked)
                {
                    m += "LastWrite";
                    File.SetLastWriteTime(f, dt);
                }
                m += "\n\nChanged To:\t" + dt.ToString() + "\n";
            }
            MessageBox.Show(m);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = this.openFileDialog1.FileName;
                button1.Enabled = true;
            }
        }



    }
}
